1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
package org.apache.geronimo.ews.ws4j2ee.wsutils;
|
18
|
|
|
19
|
|
import org.apache.axis.AxisFault;
|
20
|
|
import org.apache.axis.MessageContext;
|
21
|
|
import org.apache.axis.handlers.soap.SOAPService;
|
22
|
|
import org.apache.axis.providers.java.RPCProvider;
|
23
|
|
import org.apache.axis.utils.ClassUtils;
|
24
|
|
|
25
|
|
import java.io.InputStream;
|
26
|
|
import java.lang.reflect.Method;
|
27
|
|
|
28
|
|
|
29
|
|
|
30
|
|
|
31
|
|
|
32
|
|
|
33
|
|
public class EWSProvider extends RPCProvider {
|
34
|
|
public static final String OPTION_EJB_NAME = "beanName";
|
35
|
|
public static final String OPTION_JNDI_LOOKUP_NAME = "beanJndiName";
|
36
|
|
public static final String OPTION_HOMEINTERFACE_NAME = "homeInterfaceName";
|
37
|
|
public static final String OPTION_REMOTEINTERFACE_NAME = "remoteInterfaceName";
|
38
|
|
public static final String OPTION_LOCALHOMEINTERFACE_NAME = "localHomeInterfaceName";
|
39
|
|
public static final String OPTION_LOCALINTERFACE_NAME = "localInterfaceName";
|
40
|
|
public static final String OPTION_USE_EJB = "j2eeStyle";
|
41
|
|
|
42
|
|
private String ejblookupName;
|
43
|
|
private String localhome;
|
44
|
|
private String home;
|
45
|
|
private String remote;
|
46
|
|
private String local;
|
47
|
|
|
48
|
|
private boolean ejbbased = false;
|
49
|
|
|
50
|
2
|
protected Object makeNewServiceObject(MessageContext msgContext,
|
51
|
|
String clsName)
|
52
|
|
throws Exception {
|
53
|
2
|
SOAPService service = msgContext.getService();
|
54
|
2
|
String j2eeStyle = (String) service.getOption(OPTION_USE_EJB);
|
55
|
2
|
if("ejb".equals(j2eeStyle) ){
|
56
|
0
|
java.util.Properties env = new java.util.Properties();
|
57
|
0
|
InputStream jndiIn = ClassUtils.getResourceAsStream(getClass(), "jndi.properties");
|
58
|
0
|
if (jndiIn != null) {
|
59
|
0
|
env.load(jndiIn);
|
60
|
|
} else {
|
61
|
0
|
throw new AxisFault("Do not find the JNDI properties file in the class path");
|
62
|
|
}
|
63
|
0
|
javax.naming.Context initial = new javax.naming.InitialContext(env);
|
64
|
0
|
ejblookupName = (String) service.getOption(OPTION_JNDI_LOOKUP_NAME);
|
65
|
0
|
remote = (String) service.getOption(OPTION_REMOTEINTERFACE_NAME);
|
66
|
0
|
home = (String) service.getOption(OPTION_HOMEINTERFACE_NAME);
|
67
|
0
|
local = (String) service.getOption(OPTION_LOCALINTERFACE_NAME);
|
68
|
0
|
localhome = (String) service.getOption(OPTION_LOCALHOMEINTERFACE_NAME);
|
69
|
0
|
if (remote != null && home != null && ejblookupName != null) {
|
70
|
0
|
Object objref = initial.lookup(ejblookupName);
|
71
|
0
|
Class homeClass = ClassUtils.forName(home);
|
72
|
0
|
Object homeObj = javax.rmi.PortableRemoteObject.narrow(objref, homeClass);
|
73
|
0
|
Method method = homeClass.getMethod("create", new Class[]{});
|
74
|
0
|
return method.invoke(homeObj, new Object[]{});
|
75
|
0
|
} else if (local != null && localhome != null && ejblookupName != null) {
|
76
|
0
|
Object homeObj = initial.lookup("java:comp/" + ejblookupName);
|
77
|
0
|
Class homeClass = ClassUtils.forName(localhome);
|
78
|
0
|
Method method = homeClass.getMethod("create", new Class[]{});
|
79
|
0
|
return method.invoke(homeObj, new Object[]{});
|
80
|
|
}
|
81
|
0
|
throw new AxisFault("Wrong configuration remote="+ remote + "home =" + home + "ejblookupName" + ejblookupName );
|
82
|
|
} else {
|
83
|
2
|
return super.makeNewServiceObject(msgContext, clsName);
|
84
|
|
}
|
85
|
|
}
|
86
|
|
|
87
|
2
|
protected Object invokeMethod(MessageContext msgContext,
|
88
|
|
Method method,
|
89
|
|
Object obj,
|
90
|
|
Object[] argValues)
|
91
|
|
throws Exception {
|
92
|
2
|
Method invokeMethod = obj.getClass().getMethod(method.getName(), method.getParameterTypes());
|
93
|
2
|
return invokeMethod.invoke(obj, argValues);
|
94
|
|
}
|
95
|
|
}
|
96
|
|
|